<template>
	<Menu active-name="1-1" :open-names="['1']" style="height: 100%;width: 100%;" accordion @on-select="onSelect">
        <Submenu :name="tab.name" v-for="(tab,index) in tabs" :key="index">
            <template slot="title">
                <Icon :type="tab.icon" color="red" size="20"/>
                	{{tab.father}}
            </template>
            <MenuItem :name="son.name" v-for="(son,ind) in tab.children" :key="ind" v-if="tab.children">{{son.title}}</MenuItem>
        </Submenu>
        <Button type="error" style="width: 75%;margin-left:12.5%" @click="onSelect('5')">退出系统</Button>
    </Menu>
</template>

<script>
	export default{
		name:'tab',
		data(){
			return{
				tabs:[
					{
						father:"个人中心",
						icon:"ios-home",
						name:'u-1',
						children:[
							{
								title:'个人资料',
								name:'u-1-1'
							}
						]
					},
					{
						father:"基本资料",
						icon:"ios-paper",
						name:'1',
						children:[
							{
								title:"物资信息",
								name:'1-3'
							}
						]
					},
					{
						father:"仓库作业",
						icon:"ios-archive",
						name:"3",
						children:[
							{
								title:"入库管理",
								name:"3-1"
							},{
								title:"出库管理",
								name:"3-2"
							},{
								title:"盘损管理",
								name:"3-3"
							},{
								title:"资源申请",
								name:"3-4"
							}
						]
					},
					{
						father:"报表管理",
						icon:"ios-stats",
						name:"4",
						children:[{
								title:"入库报表",
								name:"4-2"
							},{
								title:"出库报表",
								name:"4-3"
							},{
								title:"供应商报表",
								name:"4-4"
							},{
								title:"报损报表",
								name:"4-5"
							}
						]
					}
				]
			}
		},
		methods:{
			onSelect(name){//点击tab项，触发app.vue界面的setWhitchBox方法 修改 对应的值 显示对应的box
				if(name=="5"){
					this.$Modal.confirm({
	                    title: '系统提示！',
	                    content: '<p>确定要退出登陆吗？</p>',
	                    loading: true,
	                    onOk: () => {
	                        setTimeout(() => {
	                        	this.$emit('logout',true)
	                        	this.LS.cleanLS('userInfo')
	                        	this.LS.cleanLS('userId')
	                            this.$Modal.remove();
	                            this.$Message.info('您已退出登录系统！');
	                        }, 2000);
	                    }
	                });
					return	
				}
				this.$emit('setWhitch',name)
			}
		}
	}
</script>

<style>
</style>